﻿@{
    ViewBag.Title = "stedit";
}
@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js?v=")@ViewBag.version" type="text/javascript"></script>     
    <link href="~/Scripts/miniui/themes/default/medium-mode.css" rel="stylesheet" type="text/css" />       
}

<form id="form1" method="post">
        @Html.Partial("~/Views/Modular/Toolbars.cshtml")
        <div name="Base" title="门店资料" style="height:100%;overflow:hidden;margin-top:20px;margin-left:30px">
            <table >
                <tr>
                    <td width="80px" height ="35px" align="right">门店编码：</td>
                    <td width="200px" height ="35px">
                        <input name="FNumber" id="FNumber" class="mini-textbox" style="width:200px;" value="" TabIndex="1"/>
                    </td>
                    <td width="80px" height ="35px" align="right">手机号码：</td>
                    <td width="300px" height ="35px">
                        <input id="FMobileNumber" name="FMobileNumber" class="mini-textbox " style="width:300px;" TabIndex="5"/>
                    </td>
               </tr>
                <tr>
                     <td width="80px" height ="35px" align="right">门店名称：</td>
                    <td width="200px" height ="35px">
                        <input id="FName" name="FName" class="mini-textbox " style="width:200px;" TabIndex="2"/>
                    </td>
                     <td width="80px" height ="35px" align="right">电话号码：</td>
                    <td width="300px" height ="35px">
                        <input id="FTelephone" name="FTelephone" class="mini-textbox " style="width:300px;" TabIndex="5"/>
                    </td>
               </tr>
                <tr>
                     <td width="80px" height ="35px" align="right">所属区域：</td>
                    <td width="200px" height ="35px">
                        @Html.Partial("~/Views/Modular/LookupPrvCityArea.cshtml")
                    </td>
                     <td width="80px" height ="35px" align="right">区域全称：</td>
                    <td width="300px" height ="35px">
                        <input id="FAreaAllName" name="FAreaAllName" class="mini-textbox " style="width:300px;"/>
                    </td>
               </tr>
                <tr>
                    <td width="80px" height ="35px" align="right">零售价格方案：</td>
                    <td width="200px" height ="35px">
                        @Html.Partial("~/Views/Modular/LookupGoodsPriceP.cshtml")
                    </td>
                     <td width="80px" height ="35px" align="right">地理坐标：</td>
                    <td width="300px" height ="35px">
                        <input id="FLat" name="FLat" class="mini-textbox " style="width:300px;" TabIndex="5"/>
                    </td>
               </tr>
                <tr>
                    <td width="80px" height ="35px" align="right">配送价格方案：</td>
                    <td width="200px" height ="35px">
                        @Html.Partial("~/Views/Modular/LookupGoodsPriceB.cshtml")
                    </td>
                    <td width="80px" height ="35px" align="right">详细地址：</td>
                    <td width="300px" height ="35px">
                        <input id="FAddress" name="FAddress" class="mini-textbox " style="width:300px;" TabIndex="3"/>
                    </td>
                </tr>
                <tr>
                     <td width="80px" height ="35px" align="right">门店面积：</td>
                    <td width="200px" height ="35px">
                        <input id="FAcreage" name="FAcreage" class="mini-textbox " style="width:200px;" TabIndex="6"/>
                    </td>
                     <td width="80px" height ="35px" align="right">接入商户ID：</td>
                    <td width="300px" height ="35px">
                        <input id="FChat" name="FChat" class="mini-textbox " style="width:300px;" TabIndex="7"/>
                    </td>
                </tr>
                <tr>
                     <td width="80px" height ="35px" align="right">管理人员：</td>
                    <td width="200px" height ="35px">
                        <input id="FManage" name="FManage" class="mini-textbox " style="width:200px;" TabIndex="4"/>
                    </td>
                     <td width="80px" height ="35px" align="right">
                        备注：</td>
                    <td width="300px" height ="35px">
                        <input id="FRemark" name="FRemark" class="mini-textbox " style="width:300px;" TabIndex="8"/>
                    </td>
                </tr>
            </table>
            <br />
        </div>
    <input name="FItemID" class="mini-hidden" />
</form>

<script>
    mini.parse();
    FormShown();
    function FormShown() {
        mini.getbyName("FGoodsPriceBookID").setText("00");
        mini.getbyName("FGoodsPriceBookID").setValue("0");
        mini.getbyName("FGoodsPriceBookName").setValue("默认");
        mini.getbyName("FAreaAllName").setEnabled(false);
    }


    //加载资料
    function SetInfoData(data) {
        if (data.action == "new") {
            //跨页面传递的数据对象，克隆后才可以安全使用
            mini.getbyName("FItemID").setValue('0');
            NewInfo();
        }
        else {
            $.post("GetStock", { json: "[{'FItemID':'" + data.FItemID + "','mSystemAppID':'" + parent.window.getSystemAppID() + "'}]" }, function (data) {
                var form = new mini.Form("form1");
                var mdata = mini.decode(data);
                form.setData(mdata.data[0]);
                mini.getbyName("FGoodsPriceBookID").setText(mdata.data[0].FGoodsPriceBookNumber);
                mini.getbyName("FPosPriceBookID").setText(mdata.data[0].FPosPriceBookNumber);
                mini.getbyName("FAreaID").setText(mdata.data[0].FAreaNumber);
                mini.getbyName("FItemID").setValue(mdata.data[0].FItemID);
                mini.getbyName("FNumber").setEnabled(false);
                if (mdata.data[0].FModifyFlag == 0)
                {
                    mini.getbyName("FGoodsPriceBookID").setEnabled(false);
                    mini.getbyName("FPosPriceBookID").setEnabled(false);
                }
            });
        }
    }


    //新增资料
    function NewInfo() {
        mini.getbyName("FItemID").setValue("0");
        mini.getbyName("FName").setValue("");
        mini.getbyName("FTelephone").setValue("");
        mini.getbyName("FAcreage").setValue("");
        mini.getbyName("FAddress").setValue("");
        mini.getbyName("FChat").setValue("");
        mini.getbyName("FManage").setValue("");
        mini.getbyName("FRemark").setValue("");
        var jsonstr = '{"mSystemAppID":"' + parent.window.getSystemAppID() + '"}';
        $.post('NewStockInfo', { json: jsonstr }, function (data) {
            mini.getbyName("FNumber").setValue(data);
        });
    }



    //保存资料
    function SaveInfo() {
        if (mini.getbyName("FNumber").getValue() == '') {
            mini.alert('编码不能为空');
            return;
        }
        if (mini.getbyName("FName").getValue() == '') {
            mini.alert('门店名称不能为空');
            return;
        }
        mini.getbyName("SaveInfo").setEnabled(false);
        var form = new mini.Form("#form1");
        form.validate();
        if (form.isValid() == false) {
            mini.getbyName("SaveInfo").setEnabled(true);
            return;
        }
        var data = form.getData(true, false);

        var json = mini.encode(data);
        $.post("SaveStockInfo", { json: json, mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == 1) {
                mini.showTips({ content: ret.msg, state: "success", x: "center", y: "top", timeout: 3000 });
                NewInfo();
            }
            else {
                alert("异常 : " + ret.error);
            }
            mini.getbyName("SaveInfo").setEnabled(true);
        });
    }

</script>